package vivace.view;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import vivace.helper.GUIHelper;
import vivace.model.App;

public class AboutFrame extends JFrame implements ActionListener {

	JButton discoButton;

	/**
	 * Constructor
	 */
	public AboutFrame() {
		
		setTitle(lib.Texter.Text.getText("ABOUT_VIVACE"));
		setIconImage(GUIHelper.icon);
		//setPreferredSize(new Dimension(350, 175));
		
		Container c = getContentPane();
		FlowLayout f = new FlowLayout(FlowLayout.CENTER, 10, 10);
		c.setLayout(f);
		
		JPanel p = new JPanel(new BorderLayout(0, 15));

		JLabel about = new JLabel(lib.Texter.Text.getText("ABOUT_TEXT"));
		about.setPreferredSize(new Dimension(300, 100));
		p.add(about, BorderLayout.CENTER);
		
		if (App.hasProjects()) {
			discoButton = new JButton("Let's disco!");
			discoButton.setActionCommand("disco");
			discoButton.addActionListener(this);
			setDiscoText();
			
			p.add(discoButton, BorderLayout.SOUTH);
		}
		
		c.add(p);
		
		pack();
	}
	
	private void setDiscoText() {
		if (!App.UI.getDiscoMode()) {
			discoButton.setText("Let's disco!");
		} else {
			discoButton.setText("I've had enough now...");
		}
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		String cmd = e.getActionCommand();
		
		if (cmd.equals("disco")) {
			App.UI.setDiscoMode(!App.UI.getDiscoMode());
			setDiscoText();
			
		}
		
	}
}
